package com.flashflexpro.tanksinbattle.menuscene {
import com.flashflexpro.tanksinbattle.menuscene.dto.MenuDto;
import com.flashflexpro.tanksinbattle.menuscene.dto.MenuItemDto;


public class Menu extends MenuBase {

    public function Menu(menuDto:MenuDto) {
        _menuDto = menuDto;
        for( var i:int = 0; i < _menuDto.items.length; i ++ ){
            var itemDto:MenuItemDto = _menuDto.items[ i ];
            var mi:MenuItem = new MenuItem( itemDto );
            mi.x = titleTxt.x;

            //todo: remove this
            if( mi.height <= 10 ){
                throw Error( "Haha, the height now is " + mi.height );
            }
            mi.y = titleTxt.y + titleTxt.height + MARGIN + ( mi.height + MARGIN )*i;
            addChild( mi );
        }

        titleTxt.text = _menuDto.title;
    }
    public static const MARGIN:int = 20;
    private var _menuDto:MenuDto;
}
}